package com.leetcode.剑指offer专项突击版;

/**
 * @author 覃国强
 * @date 2021-10-11 13:20
 */
public class 剑指OfferII_004_只出现一次的数字 {

  public static void main(String[] args) {
    
  }

  static
  class Solution {
    public int singleNumber(int[] nums) {
      int answer = 0;
      for (int i = 0; i < 32; ++i) {
        int sum = 0;
        for (int num : nums) {
          sum += ((num >> i) & 1);
        }
        if (sum % 3 == 1) {
          answer |= (1 << i);
        }
      }
      return answer;
    }
  }

}
